package cn.ffcs.uec.post.component;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zul.Div;

import cn.ffcs.uec.post.component.bean.UecPostEditExtBean;
import cn.ffcs.uec.post.model.UecPost;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.ListboxUtils;
import cn.ffcs.uom.common.util.PubUtil;
import cn.ffcs.uom.common.vo.NodeVo;
import lombok.Getter;
import lombok.Setter;

@Controller
@Scope("prototype")
public class UecPostEditExt extends Div implements IdSpace {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6487871788980086081L;
	/**
	 * 对应页面上的bean
	 */
	@Getter
	private UecPostEditExtBean bean = new UecPostEditExtBean();
	/**
	 * 
	 */
	private UecPost uecPost;

	@Getter
	@Setter
	private IPortletInfoProvider portletInfoProvider;

	public UecPostEditExt() {
		Executions.createComponents("/pages_nmg/uec_post/comp/uec_post_edit_ext.zul",
				this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');
		

	}

	/**
	 * 初始化
	 */
	public void onCreate() {
		// this.setButtonValid(false, false);
		bindCombobox();
	}

	/**
	 * 绑定combobox
	 */
	private void bindCombobox() {
		//启用状态
		List<NodeVo> nodeVoEndList = new ArrayList<NodeVo>();
		String[][] enablestate = {{"1", "未启用"}, {"2", "已启用"}, {"", "已停用"}};
		for (int i = 0; i < enablestate.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(enablestate[i][j]);
				nodeVo.setName(enablestate[i][j + 1]);
			}
			nodeVoEndList.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getEnablestate(), nodeVoEndList);
		
		List<NodeVo> nodeVoIsList = new ArrayList<NodeVo>();
		String[][] is = {{"Y", "是"}, {"N", "否"}};
		for (int i = 0; i < is.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(is[i][j]);
				nodeVo.setName(is[i][j + 1]);
			}
			nodeVoIsList.add(nodeVo);
		}
		//是否关键岗位
		ListboxUtils.rendererForEdit(bean.getIskeypost(),
				nodeVoIsList);
		// 是否基准岗位
		ListboxUtils.rendererForEdit(bean.getIsstd(),
				nodeVoIsList);
		// 是否基准岗位
		ListboxUtils.rendererForEdit(bean.getHrcanceled(),
				nodeVoIsList);
		//岗位体系
		List<NodeVo> list = new ArrayList<NodeVo>();
		String[][] is1 = {{"1001A1100000000005OS", "新岗位体系"}, {"1001A1100000000005OT", "旧岗位体系"}};
		for (int i = 0; i < is1.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(is1[i][j]);
				nodeVo.setName(is1[i][j + 1]);
			}
			list.add(nodeVo);
		}
		//岗位工时制度
		ListboxUtils.rendererForEdit(bean.getGlbdef1(),
				list);
		List<NodeVo> list10 = new ArrayList<NodeVo>();
		String[][] is10 = {{"1001A1100000000005OH", "不定时"}, {"1001A1100000000005OI", "综合"}, 
				{"1001A1100000000005OJ", "标准"}};
		for (int i = 0; i < is10.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(is10[i][j]);
				nodeVo.setName(is10[i][j + 1]);
			}
			list10.add(nodeVo);
		}

		ListboxUtils.rendererForEdit(bean.getGlbdef10(),
				list10);
		//岗位服务区域
		List<NodeVo> listG9 = new ArrayList<NodeVo>();
		String[][] g9 = {{"1001A1100000000005O9", "集团"}, {"1001A1100000000005OA", "省"}, 
				{"1001A1100000000005OB", "地市"},{"1001A1100000000005OC", "县"},
				{"1001A1100000000005OD", "城区区局"},{"1001A1100000000005OE", "城区支局"},
				{"1001A1100000000005OF", "农村支局"},{"1001A1100000000005OG", "营业厅"}};
		for (int i = 0; i < g9.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(g9[i][j]);
				nodeVo.setName(g9[i][j + 1]);
			}
			listG9.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getGlbdef9(),
				listG9);
		//岗位服务对象
		List<NodeVo> listG8 = new ArrayList<NodeVo>();
		String[][] g8 = {{"1001A11000000004P9YR", "只面向政企客户"}, {"1001A11000000004P9YT", "只面向公众客户"}, 
				{"1001A11000000004P9YU", "其他"}};
		for (int i = 0; i < g8.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(g8[i][j]);
				nodeVo.setName(g8[i][j + 1]);
			}
			listG8.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getGlbdef8(),
				listG8);
		//岗位等级
		List<NodeVo> listG7 = new ArrayList<NodeVo>();
		String[][] g7 = {{"1001A11000000000KXMX", "岗位等级（新体系）"}, {"1001A11000000000KXMZ", "岗位等级（旧体系）"}, 
				{"1001A11000000000KXN5", "28"},{"1001A11000000000KXN6", "27"},
				{"1001A11000000000KXN7", "26"},{"1001A11000000000KXN8", "25"},
				{"1001A11000000000KXN9", "24"},{"1001A11000000000KXNA", "23"},
				{"1001A11000000000KXNB", "22"},{"1001A11000000000KXNC", "21"},
				{"1001A11000000000KXND", "20"},{"1001A11000000000KXNF", "19"},
				{"1001A11000000000KXNG", "18"},{"1001A11000000000KXNH", "17"},
				{"1001A11000000000KXNJ", "16"},{"1001A11000000000KXNK", "15"},
				{"1001A11000000000KXNL", "14"},{"1001A11000000000KXNM", "13"},
				{"1001A11000000000KXNN", "12"},{"1001A11000000000KXNO", "11"},
				{"1001A11000000000KXNP", "10"},{"1001A11000000000KXNT", "9"},
				{"1001A11000000000KXNU", "8"},{"1001A11000000000KXNV", "7"},
				{"1001A11000000000KXNW", "6"},{"1001A11000000000KXNX", "5"},
				{"1001A11000000000KXNY", "4"},{"1001A11000000000KXNZ", "3"}};
		for (int i = 0; i < g7.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(g7[i][j]);
				nodeVo.setName(g7[i][j + 1]);
			}
			listG7.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getGlbdef7(),
				listG7);
		ListboxUtils.rendererForEdit(bean.getGlbdef6(),
				listG7);
		//岗位类别
		List<NodeVo> listG5 = new ArrayList<NodeVo>();
		String[][] g5 = {{"1001A1100000000005OL", "二类"}, {"1001A1100000000005OM", "三类"}, 
				{"1001A1100000000005ON", "四类"},{"1001A1100000000005OO", "五类"},
				{"1001A1100000000005OP", "六类"},{"1001A1100000000005OQ", "七类"},
				{"1001A1100000000005OR", "八类"}};
		for (int i = 0; i < g5.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(g5[i][j]);
				nodeVo.setName(g5[i][j + 1]);
			}
			listG5.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getGlbdef5(),
				listG5);
		//岗位层级（新体系）
		List<NodeVo> listG4 = new ArrayList<NodeVo>();
		String[][] g4 = {{"1001A1100000000005KE","管理序列"},
				{"1001A1100000000005KF","专业序列"},
				{"1001A1100000000005KG","一级正"},
				{"1001A1100000000005KH","一级副"},
				{"1001A1100000000005KI","二级正"},
				{"1001A1100000000005KJ","二级副"},
				{"1001A1100000000005KK","三级正"},
				{"1001A1100000000005KL","三级副"},
				{"1001A1100000000005KM","四级正"},
				{"1001A1100000000005KN","四级副"},
				{"1001A1100000000005KO","五级正"},
				{"1001A1100000000005KP","五级"}
				};
		for (int i = 0; i < g4.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(g4[i][j]);
				nodeVo.setName(g4[i][j + 1]);
			}
			listG4.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getGlbdef4(),
				listG4);
		//岗位层级（旧体系）
		List<NodeVo> listG3 = new ArrayList<NodeVo>();
		String[][] g3 = {{"1001A1100000000005JX","一岗"},
				{"1001A1100000000005JY","二岗"},
				{"1001A1100000000005JZ","三岗"},
				{"1001A1100000000005K0","四岗"},
				{"1001A1100000000005K1","五岗"},
				{"1001A1100000000005K2","六岗"},
				{"1001A1100000000005K3","七岗"},
				{"1001A1100000000005K4","八岗"},
				{"1001A1100000000005K5","九岗"},
				{"1001A1100000000005K6","十岗"},
				{"1001A1100000000005K7","十一岗"},
				{"1001A1100000000005K8","十二岗"},
				{"1001A1100000000005K9","十三岗"},
				{"1001A1100000000005KA","十四岗"},
				{"1001A1100000000005KB","十五岗"},
				{"1001A1100000000005KC","其他"},
				{"1001A1100000000005KD","无岗位层级"}};
		for (int i = 0; i < g3.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(g3[i][j]);
				nodeVo.setName(g3[i][j + 1]);
			}
			listG3.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getGlbdef3(),
				listG3);
	}
	/**
	 * 清除变量
	 */
	public void clearVariable() {
		uecPost = null;
	}

	/**
	 * 查询
	 */
	public void onQueryUecPostList() {
		if (null != uecPost) {
			PubUtil.fillBeanFromPo(uecPost, bean);
		}
	}
	
}
